var SelectionControl = function SelectionControl(options) {
    var this$1 = this;

    this.options = __chunk_1.extend({}, defaultOptions$1, options);

    this._container = DOM.create('div', 'mapboxgl-ctrl mapboxgl-ctrl-group');
    this._container.addEventListener('contextmenu', function (e) {
        return e.preventDefault();
    });

    if (this.options.showZoom) {
        this._zoomInButton = this._createButton('mapboxgl-ctrl-icon mapboxgl-ctrl-zoom-in', 'Zoom In', function () {
            return this$1._map.zoomIn();
        });
        this._zoomOutButton = this._createButton('mapboxgl-ctrl-icon mapboxgl-ctrl-zoom-out', 'Zoom Out', function () {
            return this$1._map.zoomOut();
        });
    }
    if (this.options.showCompass) {
        __chunk_1.bindAll([
            '_rotateCompassArrow'
        ], this);
        this._compass = this._createButton('mapboxgl-ctrl-icon mapboxgl-ctrl-compass', 'Reset North', function () {
            return this$1._map.resetNorth();
        });
        this._compassArrow = DOM.create('span', 'mapboxgl-ctrl-compass-arrow', this._compass);
    }
};

SelectionControl.prototype._rotateCompassArrow = function _rotateCompassArrow() {
    this._compassArrow.style.transform = "rotate(" + (this._map.transform.angle * (180 / Math.PI)) + "deg)";
};

SelectionControl.prototype.onAdd = function onAdd(map) {
    this._map = map;
    if (this.options.showCompass) {
        this._map.on('rotate', this._rotateCompassArrow);
        this._rotateCompassArrow();
        this._handler = new DragRotateHandler(map, {button: 'left', element: this._compass});
        DOM.addEventListener(this._compass, 'mousedown', this._handler.onMouseDown);
        this._handler.enable();
    }
    return this._container;
};

SelectionControl.prototype.onRemove = function onRemove() {
    DOM.remove(this._container);
    if (this.options.showCompass) {
        this._map.off('rotate', this._rotateCompassArrow);
        DOM.removeEventListener(this._compass, 'mousedown', this._handler.onMouseDown);
        this._handler.disable();
        delete this._handler;
    }

    delete this._map;
};

SelectionControl.prototype._createButton = function _createButton(className, ariaLabel, fn) {
    var a = DOM.create('button', className, this._container);
    a.type = 'button';
    a.setAttribute('aria-label', ariaLabel);
    a.addEventListener('click', fn);
    return a;
};
